<%@ page import="java.util.Set" %>
<%@ page import="java.util.HashSet" %>
<%@ page import="java.util.Arrays" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Product</title>
</head>
<body>
<h1>商品列表</h1>
<a href="product?name=ThinkPad">ThinkPad</a><br/>
<a  href="product?name=Lenovo">Xiaomi</a><br/>
<a  href="product?name=Apple">Apple</a><br/>
<a  href="product?name=HP">vivo</a><br/>
<a  href="product?name=SONY">Huawei</a><br/>
<a  href="product?name=ACER">ACER</a><br/>
<a  href="product?name=DEll">DEll</a><br/>

<hr/>
您浏览过的商品：
<%Cookie[] cs = request.getCookies();
    if(cs !=  null) {
        for(Cookie c:cs) {
            if(c.getName().equals("product")){
                String t=c.getValue();
                String [] ps=t.split("#");
                Set<String> productSet = new HashSet<>(Arrays.asList(ps));
                String r =productSet.toString();
                r = r.substring(1, r.length() - 1);
                out.print(r);
            }
        }
    }
%>
</body>
</html>

